package com.hzvdvmc.autosale.setting.adapter;

import android.support.v7.widget.RecyclerView;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.hzvdvmc.autosale.R;
import com.hzvdvmc.autosale.sale.bean.Good;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by william on 2017/11/18.
 * 货道商品编辑列表
 */

public class PassageWayAdapter extends RecyclerView.Adapter<PassageWayAdapter.PassageWayViewHolder> {


    private List<Good> dataList;

    @Override
    public PassageWayViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View contentView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_good_passageway, parent, false);
        return new PassageWayViewHolder(contentView);
    }

    @Override
    public void onBindViewHolder(PassageWayViewHolder holder, int position) {
        holder.edtPasswayNo.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {

            }

            @Override
            public void afterTextChanged(Editable s) {

            }
        });
        holder.edtCurrentCount.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {

            }

            @Override
            public void afterTextChanged(Editable s) {

            }
        });
        holder.edtCapacity.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {

            }

            @Override
            public void afterTextChanged(Editable s) {

            }
        });

        holder.checkboxIssale.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

            }
        });
        holder.ivDelete.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

            }
        });
    }

    @Override
    public int getItemCount() {
        return dataList == null ? 0 : dataList.size();
    }

    class PassageWayViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.iv_good)
        ImageView ivGood;
        @BindView(R.id.tv_good_name)
        TextView tvGoodName;
        @BindView(R.id.edt_passway_no)
        EditText edtPasswayNo;
        @BindView(R.id.edt_capacity)
        EditText edtCapacity;
        @BindView(R.id.edt_current_count)
        EditText edtCurrentCount;
        @BindView(R.id.tv_supplement_count)
        TextView tvSupplementCount;
        @BindView(R.id.checkbox_issale)
        CheckBox checkboxIssale;
        @BindView(R.id.iv_delete)
        ImageView ivDelete;

        public PassageWayViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}
